package com.supplychain.scm.core.task.constants;

import cn.hutool.core.io.FileUtil;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.util.Set;

/**
 * @Created with IDEA
 * @author:like
 * @Date:2022/12/27
 * @Time:11:38
 * @Description:
 */
@Slf4j
public class ExcelConstants {

	public static final String WINDOWS = "windows";

    static {
		boolean isWindows = false;
		try {
			String osName = System.getProperty("os.name");
			if(osName.toLowerCase().contains(WINDOWS)) {
				isWindows = true;
			}
		} catch (Exception e) {
			log.warn("System.getProperty(\"os.name\") error",e);
			isWindows = false;
		}
		DOWNLOAD_LOCAL_DEFAULT_DIR = isWindows ? "C:\\".concat("tmp").concat(File.separator) : File.separator.concat("tmp").concat(File.separator);
		if (!FileUtil.exist(ExcelConstants.DOWNLOAD_LOCAL_DEFAULT_DIR)) {
            FileUtil.mkdir(ExcelConstants.DOWNLOAD_LOCAL_DEFAULT_DIR);
        }
    }
	/** 默认下载目录 */
	public static String DOWNLOAD_LOCAL_DEFAULT_DIR;
    /** 限制上传文件的内存单位 */
	public static final String B = "B";
	public static final String K = "K";
	public static final String M = "M";
	public static final String G = "G";
	/** 排除字段->>>导入数据的失败原因 */
	public static final Set<String> EXCLUDE_COLUMN_FILED_NAMES = Sets.newHashSet("error");
	/** 默认excel格式 */
	public static final String DOT_FILE_TYPE_EXCEL = ".xlsx";
	/**
	 * zip 后缀
	 */
	public static final String DOT_FILE_TYPE_ZIP = ".zip";
	/** 单次导入100条 */
	public static final int LIMIT_COUNT = 100;
	/** 拆分导入500条 */
	public static final int FIVE_HUNDRED_COUNT = 500;
	/** 最大导入1万条 */
	public static final int MAX_COUNT = 10000;
	/** 5W */
	public static final int FIFTY_THOUSAND_COUNT = 50000;
	/** 单批次导出条数 */
	public static final int EXPORT_BATCH_COUNT = 200;
	public static final int ONE_THOUSAND = 1000;
	/**
	 * 导入标签
	 */
	public static final String IMPORT_LABEL = "import";
	/**
	 * 导出标签
	 */
	public static final String EXPORT_LABEL = "export";
}
